import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mahjong/entity/UserEntityInfo.dart';
import 'package:mahjong/entity/meta/MetaUserChannel.dart';
import 'package:mahjong/widget/CommonAlterDialog.dart';
import 'package:mahjong/widget/MahjongCommon.dart';
import 'package:provider/provider.dart';

typedef _CallBack = void Function(String roomCode);

class GameCenterUserInfo extends StatefulWidget {
  final _CallBack callback;
  final MetaUserChannel userChannel;

  GameCenterUserInfo({this.callback, this.userChannel});
  @override
  _GameCenterUserInfoState createState() => _GameCenterUserInfoState();
}

class _GameCenterUserInfoState extends State<GameCenterUserInfo> {
  double dialogHeight, dialogWidth;
  MetaUserChannel _userChannel;

  List<String> interactions = [
    "images/interaction/main/icon_fanqie.png",
    "images/interaction/main/icon_boom.png",
    "images/interaction/main/icon_shuitong.png",
    "images/interaction/main/icon_meigui.png",
    "images/interaction/main/icon_kiss.png"
  ];

  @override
  void initState() {
    super.initState();
    dialogHeight = 160.h;
    dialogWidth = 400.w;
    _userChannel = widget.userChannel;
  }

  @override
  Widget build(BuildContext context) {
    return CommonAlterDialog(
        height: dialogHeight,
        width: dialogWidth,
        backgroundColor: Colors.white,
        child: Consumer(builder:
            (BuildContext buildContext, UserEntityInfo provider, Widget child) {
          return Center(
            child: Column(
              children: [
                Container(
                    padding: EdgeInsets.symmetric(horizontal: 20.w),
                    height: 80.h,
                    decoration: BoxDecoration(
                      gradient: LinearGradient(
                        begin: Alignment.centerLeft,
                        end: Alignment.centerRight,
                        colors: [
                          Colors.lightBlue[200],
                          Colors.white,
                        ],
                      ),
                    ),
                    child: Row(
                      children: [
                        Container(
                          child: MahjongCommon.headerImage(
                              _userChannel.sysUser.portraitUrl,
                              width: 50.h,
                              height: 50.h),
                        ),
                        SizedBox(width: 20.w),
                        Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(
                              "名称:" + _userChannel.sysUser.username,
                              style: TextStyle(fontSize: 12.sp),
                            ),
                            Text(
                              "ID:" + _userChannel.sysUser.id.toString(),
                              style: TextStyle(fontSize: 18.sp),
                            ),
                          ],
                        )
                      ],
                    )),
                Divider(
                  height: 1.00,
                  indent: 1.00,
                  color: Colors.blue.withOpacity(0.8),
                ),
                Expanded(
                    child: Container(
                  width: dialogWidth,
                  child: SingleChildScrollView(
                    scrollDirection: Axis.horizontal,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: interactions
                          .map(
                            (e) => InkWell(
                                splashColor: Colors.blue,
                                child: Container(
                                  margin: EdgeInsets.only(left: 10.h),
                                  padding: EdgeInsets.all(5.h),
                                  child: Image.asset(
                                    e,
                                    fit: BoxFit.contain,
                                  ),
                                  height: 40.h,
                                  width: 40.h,
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(30.h),
                                      border: Border.all(
                                        color: Colors.red,
                                      )),
                                )),
                          )
                          .toList(),
                    ),
                  ),
                ))
              ],
            ),
          );
        }));
  }
}
